var API = {};
API.GLOBAL = {};
API.APPS = {};

//ajax加载方法
API.GLOBAL.ajax = function (url, method, params, dataType, callback) {
    $.ajax({
        url: url,
        type: method,
        data: params,
        dataType: dataType,
        success: callback,
        error: function () {
            alert('请求异常');
        }
    });
};


//QUERYPHONE方法
API.APPS.QUERYPHONE = {};
API.APPS.QUERYPHONE.dataCallback = function (data) {
    if (data.code == 200) {
        $('#phone-number').text(data.telString);
        $('#phone-province').text(data.province);
        $('#phone-catName').text(data.catName);
        $('#phone-msg').text(data.msg);
    } else {
        alert(data.msg);
    }
};


//QUERYIP方法
API.APPS.QUERYIP = {};
API.APPS.QUERYIP.dataCallback = function (data) {
    if (data.code == 200) {
        $('#ip-number').text(data.ip);
        $('#ip-country').text(data.country);
        $('#ip-province').text(data.province);
        $('#ip-city').text(data.city);
        $('#ip-district').text(data.district);
        $('#ip-carrier').text(data.carrier);
        $('#ip-msg').text(data.msg);
    } else {
        alert(data.msg);
    }
};

//SHORTURL方法
API.APPS.SHORTURL = {};
API.APPS.SHORTURL.dataCallback = function (data) {
    if (data.code == 200) {
        $('#url-long').text(data.url_long);
        $('#url-short').text(data.url_short);
        document.getElementById("url-img").src = data.img;
    } else {
        alert(data.msg);
    }
};
